<?php

defined('_JEXEC') or die('Restricted access');

/**
 * table class
 */
class taxibooking_routes extends JTable
{
	/**
	 * Primary Key
	 * @var int
	 */
	var $id 				= null;
	/** @var string */
	var $title 				= '';
	/** @var string */
	var $alias	 			= '';
	/** @var string */
	var $from	 		= '';
	/** @var string */
	var $to	 		= '';
        /** @var string */
	var $price	 		= '';
	/** @var date */
	var $created			= '';
	/** @var int */
	var $created_by			= '';
	/** @var int */
	var $published			= null;
	/** @var int */
	var $ordering 			= null;

	function taxibooking_routes(& $db) {
		parent::__construct('#__taxibooking_routes', 'id', $db);
	}
	
	// overloaded check function
	function check()
	{
		// Not typed in a title?
		if (trim( $this->title ) == '') {
			$this->_error = JText::_( 'ADD TITLE' );
			JError::raiseWarning('SOME_ERROR_CODE', $this->_error );
			return false;
		}
                
                // Not typed in a title?
		if (trim( $this->from ) == '') {
			$this->_error = 'Add From Location';
			JError::raiseWarning('SOME_ERROR_CODE', $this->_error );
			return false;
		}
                
                // Not typed in a title?
		if (trim( $this->to ) == '') {
			$this->_error = 'Add To Location';
			JError::raiseWarning('SOME_ERROR_CODE', $this->_error );
			return false;
		}

		$alias = JFilterOutput::stringURLSafe($this->title);

		if(empty($this->alias) || $this->alias === $alias ) {
			$this->alias = $alias;
		}
		
		return true;
	}
}
?>